/**
 * 
 */
package routing.table;

import java.util.HashMap;

import routing.RoutingProtocol;
import routing.route.Route;

/**
 * @author chevy
 *
 */
public class RouteTable {
	
	private HashMap<String,Route> routingEntries;
	
	public RouteTable(){
		routingEntries = new HashMap<String, Route>();
	}
	
	public String routePacket(String destinationAddres, RoutingProtocol protocol) throws Exception{
		if(routingEntries.containsKey(destinationAddres)){
			
			return protocol.getDestinationRoute(routingEntries.get(destinationAddres));
		}
		else
			throw new Exception(String.format(
					"La dirección de destino %s no se encuentra en la tabla de enrutamiento",
					destinationAddres));
	}
	
	public void evaluateRoute(Route route){
		String destination = route.getDestinantionNetwork();
		
		routingEntries.put(destination, route);
	}
	
}
